import { getPageTitle } from '@ant-design/pro-layout'
import pubSub from 'pubsub-js'
import Dialog from './view/Dialog'
import DialogModal from './view/DialogModal'
import { Button, Modal } from 'antd';
import React, { createContext, Dispatch, useState, useContext } from "react"

import DialogContext from './view/dialogContext'
import useDialog from './view/useDialog'


export default () => {
    const { dialogStack, dispatch } = useDialog()
    function view() {
        const back = () => {
            dispatch({
                type: 'back'
            })
        }

        const close = () => {
            dispatch({
                type: 'close'
            })
        }

        const openElse = () => {
            dispatch({
                type: 'open',
                dialogFlag: 'ContactUs',
                dialogProps: {
                    data: { name: "标题呢ContactUs" },
                    back
                },

            })
        }

        const openDialog = () => {
            dispatch({
                type: 'open',
                dialogFlag: 'AboutUs',
                dialogProps: {
                    data: { name: "标题呢AboutUs" },
                    dispatch,
                    close,

                },

            })
        }

        return <div>
            <button onClick={openDialog}> dispatch Dialog</button>
            {/*调出滚动条*/}
            <div style={{
                width: '200px',
                height: '1500px',
                backgroundColor: '#2b2b2b'
            }} />
            <DialogContext.Provider value={{ dialogStack, dispatch }}>
                <>

                    <Dialog />
                </>
            </DialogContext.Provider>
        </div>
        // return <div>

        //     <div onClick={() => {
        //         setDisplay(true)
        //     }}>
        //         Display
        //     </div>

        //     {/* {
        //         display
        //         &&
        //         <Dialog>
        //             <DialogModal />
        //         </Dialog>
        //     } */}
        //     {/* <Button type="primary" onClick={showModal}>
        //         Open Modal
        //     </Button>
        //     <Modal title="Basic Modal" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
        //         <p>Some contents...</p>
        //         <p>Some contents...</p>
        //         <p>Some contents...</p>
        //     </Modal> */}
        // </div>
    }
    return (
        view()
    );

};